import { Component, OnInit } from '@angular/core';
import { Singlepage } from '../../model/singlepage';
import { SinglepageService } from '../../service/singlepage.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-singlepagelist',
  templateUrl: './singlepagelist.component.html',
  styleUrls: ['./singlepagelist.component.css']
})
export class SinglepagelistComponent implements OnInit {
  sl:Array<Singlepage>;
  constructor(
    private singlepageservice:SinglepageService,
    private router:Router) {
    this.sl=new Array();
   }

  ngOnInit() {
    this.sl=new Array();
    this.singlepageservice.getSinglepageList()
    .then((data:any)=>{
      this.sl=data;
      console.log(this.sl[0].title);
    })
  }

  toDetail(id:string){
    this.router.navigate(['singlepagedetail',id]);
  }

}
